'''
Created on 2010-3-3

@author: Administrator
'''
import sys
import warnings
from jolly.datastructures.Object import Object

class Integer(int, Object):
    '''
    Integer class
    '''


    def __init__(self, obj):
        '''
        (Integer, object) -> None
        Constructs a string with the string representation of the given object.
        The Object metaclass provides a __new__ method
        that initializes the str instance, so none is defined here.
        '''
        pass
    
    def _compareTo(self, obj):
        '''
        (Integer, Integer) -> int

        Compares this string with the given string.
        '''
        assert isinstance(self, obj.__class__)
        return cmp(int(self), int(obj))
    
    def __hash__(self):
        '''
        (Integer) -> int
        Hashes this string.
        '''
        return self & sys.maxint
    
    @staticmethod
    def testHash():
        "Integer hash test program."
        print Integer.testHash.__doc__
        print "57=%d" % hash(Integer(57))
        print "-123=%d" % hash(Integer(-123))

    @staticmethod
    def main(*argv):
        "Integer test program."
        print Integer.main.__doc__
        Integer.testHash()
        return 0

if __name__ == "__main__":
    sys.exit(Integer.main(*sys.argv))